﻿using MediatR;
using SystemHYS.API.Application.command.ProductionRequisitionCommand;
using SystemHYS.Infrstructre.Interface;
using SystemHYS.Infrstructre;
namespace SystemHYS.API.Application.commandler.ProductionRequisitionCommandler
{
    public class ProductionRequisitionDeleteCommandler : IRequestHandler<ProductionRequisitionDeleteCommand, int>
    {
        IRawMaterialProductionRepository rawMaterialProductionRepository;
        IProductionRequisitionRepository productionRequisitionRepository;
        public SystemCoretext db;
        public ProductionRequisitionDeleteCommandler(IRawMaterialProductionRepository rawMaterialProductionRepository, IProductionRequisitionRepository productionRequisitionRepository, SystemCoretext db)
        {
            this.rawMaterialProductionRepository = rawMaterialProductionRepository;
            this.productionRequisitionRepository = productionRequisitionRepository;
            this.db = db;
        }
        public async Task<int> Handle(ProductionRequisitionDeleteCommand request, CancellationToken cancellationToken)
        {
            var list = await productionRequisitionRepository.GetModelAsnc(request.productionRequisitionId);
            list.Isdel = true;
            list.DelectName = "李明";
            list.DelectTime = DateTime.Now.ToUniversalTime();
            return await productionRequisitionRepository.UpdateAsyn(list);
        }
    }
}
